home *** CD-ROM | disk | FTP | other *** search
- (*===========================================================================*)
- (* User task *)
- (* *)
- (* Copyright 1988, 1989, 1991, 1992 by H. Roy Engehausen. All rights *)
- (* reserved. *)
- (* *)
- (*===========================================================================*)
-
- {$O+}
-
- UNIT BBUSER;
-
- INTERFACE
-
- PROCEDURE user_start;
-
- IMPLEMENTATION
-
- USES
- bbanswer,
- bbauth,
- bbconv,
- bbdummy,
- bblc,
- bbmdata,
- bbmess,
- bbmf,
- bbmisc,
- bbmisc2,
- bbrdata,
- bbreg,
- bbsdata,
- bbsess,
- bbstarl,
- bbstr,
- bbtask,
- bbtime,
- bbucmd,
- bbuserno,
- bbwin;
-
- (*===========================================================================*)
- (* This is the main user task *)
- (*===========================================================================*)
-
- PROCEDURE user_start;
-
- VAR
-
- bb_sign_on_done : BOOLEAN;
- user_reject : BOOLEAN;
- star_l_done : BOOLEAN;
- cmd_string : STRING;
- link_restart : BOOLEAN;
-
- LABEL opr_want_talk;
- LABEL link_loop;
-
- (*=========================================================================*)
- (* This subroutine does *** LINK stuff *)
- (*=========================================================================*)
-
- PROCEDURE process_star_link;
-
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Call the *** LINK procedure *)
- (*---------------------------------------------------------------*)
-
- link_restart := star_link(cmd_string);
-
- (*---------------------------------------------------------------*)
- (* If it failed, end the session *)
- (*---------------------------------------------------------------*)
-
- IF NOT link_restart THEN
- end_session(FALSE);
-
- END;
-
- (*=========================================================================*)
- (* User security *)
- (*=========================================================================*)
-
- PROCEDURE user_secure_check;
- BEGIN;
-
- WITH active_tcb^.uid_data DO
- BEGIN;
-
- (*-----------------------------------------------------------------*)
- (* Assume everything is bad *)
- (*-----------------------------------------------------------------*)
-
- active_tcb^.error_sw := TRUE;
-
- (*-----------------------------------------------------------------*)
- (* Build the task access control area *)
- (*-----------------------------------------------------------------*)
-
- active_tcb^.tcb_access_mode.access_flags :=
- user_access.access_flags
- AND active_port^.dflt_access.access_flags;
-
- (*-----------------------------------------------------------------*)
- (* Drop user if excluded *)
- (*-----------------------------------------------------------------*)
-
- IF (user_flag AND user_f_exclude) <> 0 THEN
-
- EXIT;
-
- (*-----------------------------------------------------------------*)
- (* Drop user if class not allowed on this port (remote sysops are *)
- (* exempt from this rule) *)
- (*-----------------------------------------------------------------*)
-
- IF (user_class < active_port^.port_allow)
- AND ((user_flag AND user_f_sysop) = 0) THEN
- EXIT;
-
- (*-----------------------------------------------------------------*)
- (* Assume everything after this is OK. *)
- (*-----------------------------------------------------------------*)
-
- active_tcb^.error_sw := FALSE;
- active_tcb^.tcb_error_reason := 0;
-
- (*-----------------------------------------------------------------*)
- (* Should user authenticate now? If not we are done *)
- (*-----------------------------------------------------------------*)
-
- IF (active_tcb^.tcb_access_mode.access_flags
- AND access_f_user) = 0 THEN
- EXIT;
-
- (*-----------------------------------------------------------------*)
- (* If this is a BBS, skip the authentication now. Catch it later *)
- (* in the command processor *)
- (*-----------------------------------------------------------------*)
-
- IF (user_flag AND (user_f_bbs OR user_f_pbbs)) <> 0 THEN
- EXIT;
-
- (*-----------------------------------------------------------------*)
- (* Call the authenticator *)
- (*-----------------------------------------------------------------*)
-
- user_auth(cmd_string);
-
- (*-----------------------------------------------------------------*)
- (* Set the result code *)
- (*-----------------------------------------------------------------*)
-
- IF NOT active_tcb^.error_sw THEN
- BEGIN;
- active_tcb^.tcb_access_ok := TRUE;
- active_tcb^.tcb_sysop_pw_ok := TRUE;
- (* We can always turn this on even if *)
- (* user is not authorized since he *)
- (* can't get into remote sysop status *)
- (* without the proper bit *)
- END;
-
- END;
-
- END;
-
- (*=========================================================================*)
- (* Check the access *)
- (*=========================================================================*)
-
- PROCEDURE access_test;
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Test for BBS *)
- (*---------------------------------------------------------------------*)
-
- IF (active_tcb^.uid_data.user_flag
- AND (user_f_bbs OR user_f_pbbs)) <> 0 THEN
- BEGIN;
-
- (*-----------------------------------------------------------------*)
- (* If all they want is reverse forward, let them *)
- (*-----------------------------------------------------------------*)
-
- IF cmd_string = 'F>' THEN
- EXIT;
-
- EXIT;
-
- END;
-
- IF cmd_string[1] <> 'S' THEN
- EXIT;
-
-
- END;
-
- (*=========================================================================*)
- (* This subroutine decodes the command *)
- (*=========================================================================*)
-
- PROCEDURE user_command_decode;
-
- BEGIN;
-
- (*---------------------------------------------------------------------*)
- (* Handle the sign on for an advanced bbs *)
- (* This is an incoming command for the following format: *)
- (* [xxxxxxx-fff] *)
- (*---------------------------------------------------------------------*)
-
- WITH active_tcb^ DO
- IF (cmd_string[1] = '[') AND (NOT bb_sign_on_done) THEN
-
- BEGIN;
-
- (*---------------------------------------------------------------*)
- (* Process the SID if this is one *)
- (*---------------------------------------------------------------*)
-
- process_sid(@cmd_string);
- bb_sign_on_done := TRUE;
- star_l_done := FALSE;
- active_port^.modem_crlf := FALSE;
-
- EXIT;
-
- END;
-
- (*---------------------------------------------------------------------*)
- (* Handle *** LINKED *)
- (*---------------------------------------------------------------------*)
-
- IF (NOT star_l_done)
- AND substr_compare(cmd_string, 1, '*** LINKED') THEN
- BEGIN;
- process_star_link;
- EXIT;
- END;
-
- (*---------------------------------------------------------------------*)
- (* If no authentication at this point, see if an allowed command. *)
- (* We will always allow a "@". We may not allow an "S" sometimes *)
- (*---------------------------------------------------------------------*)
-
- IF NOT active_tcb^.tcb_access_ok AND (cmd_string[1] <> '@') THEN
- BEGIN;
- access_test;
- IF active_tcb^.error_sw THEN
- EXIT;
- END;
-
- (*---------------------------------------------------------------------*)
- (* Normal user command *)
- (*---------------------------------------------------------------------*)
-
- bb_sign_on_done := TRUE;
- star_l_done := TRUE;
- user_command(cmd_string);
-
- END;
-
- (*=========================================================================*)
- (* The actual user task *)
- (*=========================================================================*)
-
- BEGIN;
-
- (*-----------------------------------------------------------------------*)
- (* Make sure we show connected properly *)
- (*-----------------------------------------------------------------------*)
-
- active_port^.connected^[active_tcb^.channel] := active_tcb;
-
- (*-----------------------------------------------------------------------*)
- (* If a modem then we have an incoming call *)
- (*-----------------------------------------------------------------------*)
-
- IF active_port^.port_type = port_modem THEN
- answer_modem;
-
- (*-----------------------------------------------------------------------*)
- (* Show that we are a user task *)
- (*-----------------------------------------------------------------------*)
-
- active_tcb^.tcb_type := th_user;
-
- (*-----------------------------------------------------------------------*)
- (* Initialize the link *)
- (*-----------------------------------------------------------------------*)
-
- link_restart := FALSE;
-
- link_start;
-
- (*-----------------------------------------------------------------------*)
- (* If this is a modem then maybe we have authenticated *)
- (*-----------------------------------------------------------------------*)
-
- IF (active_port^.port_type = port_modem)
- AND (active_tcb^.uid_data.user_pw <> '') THEN
- BEGIN;
- active_tcb^.tcb_sysop_pw_ok := TRUE;
- active_tcb^.tcb_access_ok := TRUE;
- END;
-
- (*-----------------------------------------------------------------------*)
- (* This point is used when we change call signs in response to *)
- (* *** LINKED, etc *)
- (*-----------------------------------------------------------------------*)
-
- link_loop:
-
- WITH active_tcb^.uid_data DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Set the attributes *)
- (*-------------------------------------------------------------------*)
-
- IF (user_flag AND (user_f_bbs OR user_f_pbbs)) <> 0 THEN
- BEGIN;
- bb_sign_on_done := FALSE;
- star_l_done := link_restart;
- END
- ELSE
- BEGIN;
- bb_sign_on_done := TRUE;
- star_l_done := TRUE;
- END;
-
- link_restart := FALSE;
-
- (*-------------------------------------------------------------------*)
- (* Check for reject because of emergency mode *)
- (*-------------------------------------------------------------------*)
-
- user_reject := active_port^.port_operate_mode.mode_e_users
- AND opt_block.operate_mode.mode_e_users
- AND ((user_flag AND user_f_emerg) = 0);
-
- (*-------------------------------------------------------------------*)
- (* If emode reject, give user a chance if desired *)
- (*-------------------------------------------------------------------*)
-
- IF user_reject AND active_port^.port_operate_mode.mode_user_change
- AND opt_block.operate_mode.mode_user_change THEN
- BEGIN;
- call_switch(cmd_string);
- GOTO link_loop;
- END;
-
- (*-------------------------------------------------------------------*)
- (* Drop user emergency mode and user is not authorized or *)
- (* not emergency mode and user is not secure *)
- (*-------------------------------------------------------------------*)
-
- IF NOT active_port^.port_operate_mode.mode_e_users THEN
- BEGIN;
- user_secure_check;
- user_reject := active_tcb^.error_sw;
- END;
-
- IF user_reject THEN
- BEGIN;
- send_message(message_not_on_port);
- end_session(FALSE);
- END;
-
- (*-------------------------------------------------------------------*)
- (* Sign on for "advanced BBS" *)
- (*-------------------------------------------------------------------*)
-
- IF ((user_flag AND (user_f_bbs OR user_f_pbbs)) <> 0)
- OR opt_block.opt_send_sid_alwys THEN
- send_tnc_data_str(this_bbs_handshake + cr);
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Send the sign on message *)
- (*-----------------------------------------------------------------------*)
-
- IF active_port^.port_type = port_modem THEN
- send_message(message_signon_modem)
- ELSE
- send_message(message_signon);
-
- (*-----------------------------------------------------------------------*)
- (* If not a special user, then give signals *)
- (*-----------------------------------------------------------------------*)
-
- IF active_tcb^.uid_data.user_class <= user_c_eu THEN
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* Must register now? *)
- (*-------------------------------------------------------------------*)
-
- IF (active_tcb^.uid_data.user_class <= user_c_uu)
- AND active_port^.port_force_register THEN
- BEGIN;
- send_message(message_must_register);
- register_cmd('N');
- IF active_tcb^.error_sw THEN
- end_session(FALSE);
- END;
-
- (*-------------------------------------------------------------------*)
- (* Reregister? *)
- (*-------------------------------------------------------------------*)
-
- IF (((user_f_bbs OR user_f_pbbs OR user_f_sysop OR user_f_adrchg)
- AND active_tcb^.uid_data.user_flag) = 0)
- AND ((current_day_time - opt_block.home_expires)
- > active_tcb^.uid_data.user_n_time)
- AND (LENGTH(opt_block.wp_bb_sign) <> 0) THEN
- send_message(message_reregister);
-
- (*-------------------------------------------------------------------*)
- (* Unread mail? *)
- (*-------------------------------------------------------------------*)
-
- IF find_mail('R') THEN
- send_message(message_unread);
-
- (*-------------------------------------------------------------------*)
- (* Read mail? *)
- (*-------------------------------------------------------------------*)
-
- IF find_mail('Q') THEN
- send_message(message_unkill_read);
-
- END;
-
- (*-----------------------------------------------------------------------*)
- (* Main loop.... We never leave *)
- (*-----------------------------------------------------------------------*)
-
- WHILE TRUE DO
- BEGIN;
-
- (*-------------------------------------------------------------------*)
- (* If operator is going to talk then do it *)
- (*-------------------------------------------------------------------*)
-
- opr_want_talk:
-
- WITH active_tcb^ DO
- IF tcb_opr_talk THEN
- BEGIN;
- window := window_operator;
- send_message(message_o_talk_to_u);
- converse_talk_loop;
- window := window_connect;
- send_message(message_bbs_mode);
- END;
-
- (*-------------------------------------------------------------------*)
- (* Clear the error switch *)
- (*-------------------------------------------------------------------*)
-
- active_tcb^.error_sw := FALSE;
-
- (*-------------------------------------------------------------------*)
- (* Send prompt *)
- (*-------------------------------------------------------------------*)
-
- send_message(message_prompt);
- send_flush;
- task_switch;
-
- (*-------------------------------------------------------------------*)
- (* Wait for something to happen *)
- (*-------------------------------------------------------------------*)
-
- user_loop;
-
- (*-------------------------------------------------------------------*)
- (* See if operator wants something *)
- (*-------------------------------------------------------------------*)
-
- IF active_tcb^.tcb_opr_talk THEN
- GOTO opr_want_talk;
-
- (*-------------------------------------------------------------------*)
- (* Response arrived so get it *)
- (*-------------------------------------------------------------------*)
-
- cmd_string := read_tnc_data_str;
-
- (*-------------------------------------------------------------------*)
- (* Process the user's command *)
- (*-------------------------------------------------------------------*)
-
- user_command_decode;
-
- (*-------------------------------------------------------------------*)
- (* Restart the link if *** LINK was done *)
- (*-------------------------------------------------------------------*)
-
- IF link_restart THEN
- GOTO link_loop;
-
- (*-------------------------------------------------------------------*)
- (* If this is a BBS and an error has occurred, dump the session. *)
- (*-------------------------------------------------------------------*)
-
- WITH active_tcb^ DO
- IF error_sw AND (uid_data.user_class = user_c_bu) AND
- opt_block.opt_kill_bbs_error THEN
- end_session(FALSE);
-
- END; (*----- End main loop --------------------------------------------*)
-
- END;
-
- END.